package com.tmp.alarm;

import com.tmp.alarm.task.SmallFileNumPercAlarm;
import com.tmp.alarm.utils.PropertiesUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 */
public class StartTask {

    private  final  static Logger LOGGER = LoggerFactory.getLogger(StartTask.class);

    public static void main(String[] args) {

        int limit_time = Integer.parseInt(PropertiesUtil.get("task_limit_time").trim());

//        LOGGER.info("******任务开始运行*****");
//        CountJobAlarm.countSubJobWaysRateAlarm();
//        LOGGER.info("******一次任务运行结束*****\n\n\n");

      Runnable runnable = new Runnable() {
            public void run() {
                try {
                    LOGGER.info("******任务开始运行*****");

                    System.out.println("任务开始运行");

//                    MartMobileJobInfo.insertJobInfo2Mysql();
//                    MartMobileQueueInfo.insertQueueInfo2Mysql();//读取mart_mobile_queue文件并将基础数据存储到数据库中，然后删除mart_mobile_queue文件，并  疑问：/home/mart_mobile/wl/jobMonitor/mart_mobile_queue这个文件什么时候生成？多久生成一次？
//                    CountJobAlarm.countSubJobWaysRateAlarm();
//                    ProgressAlarm.dealProgressAlarm();
//                    JobSpendTimeAlarm.countJobSpendTime();

//                    CountQueueVocreAlarm.countVcoreRateAlarm();

                    SmallFileNumPercAlarm.smallFileNumPercAlarmAlarm();

                    LOGGER.info("******一次任务运行结束*****\n\n\n");

                   /* LOGGER.info("代码段1......");
                    Thread.sleep(200);
                    LOGGER.info("代码段2......");
                    Thread.sleep(200);
                    LOGGER.info("代码段3......");
                    Thread.sleep(200);
                    LOGGER.info("代码段4......");
                    Thread.sleep(200);
                    LOGGER.info("代码段5......");*/
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        };
        ScheduledExecutorService service = Executors
                .newSingleThreadScheduledExecutor();
        // 第二个参数为首次执行的延时时间，第三个参数为定时执行的间隔时间,第四个参数是单位(有秒s分min毫秒microSeconds等)
        service.scheduleAtFixedRate(runnable,3,limit_time, TimeUnit.SECONDS);
    }
}
